package main

import "fmt"

// 起别名
type myInt int

// 定义结构体
type book struct {
	title  string
	author string
	price  float64
}
//首字母大写能被其他包发现
func (b *book) SetName(name string) {
	b.title = name
}
func (b *book) GetName() string {
	return b.title
}

// 类传参为值传递
func printBook(b book) {
	fmt.Printf("%v\n", b)
	b.title = "C++"
}

// 指针传递
func printBook2(b *book) {
	fmt.Printf("%v\n", b)
	b.title = "C++"
}
func goStruct() {
	var a myInt = 10
	fmt.Printf("type:%T value:%v\n", a, a)

	var book1 book
	book1.title = "Go语言"
	book1.author = "张三"
	book1.price = 99.99
	printBook(book1)
	printBook(book1)

	printBook2(&book1)
	printBook(book1)
	book1.SetName("Python")
	fmt.Println(book1.GetName())
}
